import {UserApi, ProductApi, CartApi, type CartProductRO} from '@/api'
import globalAxios from "axios";

class CartService {
    private axiosInstance = globalAxios;
    private cartApi = new CartApi(undefined, import.meta.env.VITE_API_URL, this.axiosInstance);

    getCartInfo(userId: string) {
        return this.cartApi.getCart(userId).then((response) => {
            return response;
        }).catch((error) => {
            console.error("Error fetching cart info", error);
            throw error;
        });
    }

    addToCart(cartProductRO: CartProductRO) {
        return this.cartApi.addProduct1(cartProductRO).then((response) => {
            return response;
        })
    }

}
export const cartService: CartService = new CartService();